package org.springside.examples.miniweb.entity.account;

import java.util.Map;

import com.google.common.collect.Maps;

/**
 * Resource Base Access Control中的资源定义.
 * 
 * @author calvin
 */
public enum Permission {

	USER_VIEW("user:view", "查看用戶(A)"), 
	USER_EDIT("user:edit", "修改当前用户"),
	USER_SUPER_EDIT("user:superedit", "高级修改用户信息权限(A)"),
	CUSTOMER_VIEW("customer:view", "查看客户"), 
	CUSTOMER_EDIT("customer:edit", "修改客户(A)"),
	GROUP_VIEW("group:view", "查看权限组(A)"),
	GROUP_EDIT("group:edit", "修改权限组(A)"),
	VALID_LOGIN("login", "合法登陆"),
	VALID_LOGOUT("logout", "合法登出"),
	COMPUMP_VIEW("compump:view","查看压缩机维修报表(S)"),
	COMPUMP_EDIT("compump:edit","编辑压缩机维修报表"),
	COMPUMP_SUPER_EDIT("report:superedit","高级维修报表编辑权限(AS)--可以修改已经分配给员工的报表"),
	COMPUMP_DELETE("compump:delete","删除压缩机维修报表(A)"),
	COLDPUMP_VIEW("coldpump:view","查看冷泵维修报表(S)"),
	COLDPUMP_EDIT("coldpump:edit","编辑冷泵维修报表"),
	COLDPUMP_DELETE("coldpump:delete","删除冷泵维修报表(A)"),
	BACKPUMP_VIEW("backpump:view","查看备泵维修报表"),
	BACKPUMP_EDIT("backpump:edit","编辑备泵维修报表"),
	BACKPUMP_DELETE("backpump:delete","删除备泵维修报表(A)"),
	PERFORMANCE_VIEW("performance:view","查看绩效报表(S)"),
	PROCESS_VIEW("process:view","查看进度报表");

	public String value;
	public String displayName;
	private static Map<String, Permission> valueMap = Maps.newHashMap();

	static {
		for (Permission permission : Permission.values()) {
			valueMap.put(permission.value, permission);
		}
	}

	Permission(String value, String displayName) {
		this.value = value;
		this.displayName = displayName;
	}

	public static Permission parse(String value) {
		return valueMap.get(value);
	}

	public String getValue() {
		return value;
	}

	public String getDisplayName() {
		return displayName;
	}
}
